/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.eclipse.persistence.annotations.CascadeOnDelete;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "VesselCleaningProcedure")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "VesselCleaningProcedure.findAll", query = "SELECT v FROM VesselCleaningProcedure v ORDER BY v.vCPDesc ASC"),
    @NamedQuery(name = "VesselCleaningProcedure.findByVcpid", query = "SELECT v FROM VesselCleaningProcedure v WHERE v.vcpid = :vcpid"),
    @NamedQuery(name = "VesselCleaningProcedure.findByVCPDesc", query = "SELECT v FROM VesselCleaningProcedure v WHERE v.vCPDesc = :vCPDesc"),
    @NamedQuery(name = "VesselCleaningProcedure.findByVCPRepeatDays", query = "SELECT v FROM VesselCleaningProcedure v WHERE v.vCPRepeatDays = :vCPRepeatDays")})
public class VesselCleaningProcedure implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "VCPID")
    private Integer vcpid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "VCPDesc")
    private String vCPDesc;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 0, max = 16777215)
    @Column(name = "VCPProcedure")
    private String vCPProcedure;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VCPRepeatDays")
    private int vCPRepeatDays;
    @Basic(optional = false)
    @NotNull
    @Column(name = "taskMinutes")
    private int taskMinutes;
    @Basic(optional = false)
    @NotNull
    @Column(name = "taskMen")
    private int taskMen;
    @Basic(optional = false)
    @NotNull
    @Column(name = "rateType")
    private int rateType;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vCProcedureID")
    private Collection<VesselCleaningHistory> vchCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "eCProcedureID")
    private Collection<EquipmentCleaningHistory> echCollection;
    @OneToMany(cascade=CascadeType.REFRESH, fetch=FetchType.EAGER)
    @JoinTable(
        name="JTVCPTODoc",
        joinColumns={ @JoinColumn(name="VCPID", referencedColumnName="VCPID")},
        inverseJoinColumns={ @JoinColumn(name="docID", referencedColumnName="docID", unique=true)}
    )
    private List<Documents> docCollection;
    @OneToMany(cascade=CascadeType.ALL, orphanRemoval = true)
    @CascadeOnDelete
    @JoinTable(
        name="JTVCPToInvUsage",
        joinColumns={ @JoinColumn(name="VCPID", referencedColumnName="VCPID")},
        inverseJoinColumns={ @JoinColumn(name="InvUsageID", referencedColumnName="InvUsageID", unique=true)}
    )
    private List<InventoryUsage> invUsageCollection;


    public VesselCleaningProcedure() {
    }

    public VesselCleaningProcedure(Integer vcpid) {
        this.vcpid = vcpid;
    }

    public VesselCleaningProcedure(Integer vcpid, String vCPDesc, String vCPProcedure, int vCPRepeatDays) {
        this.vcpid = vcpid;
        this.vCPDesc = vCPDesc;
        this.vCPProcedure = vCPProcedure;
        this.vCPRepeatDays = vCPRepeatDays;
    }

    public Integer getVcpid() {
        return vcpid;
    }

    public void setVcpid(Integer vcpid) {
        this.vcpid = vcpid;
    }

    public String getVCPDesc() {
        return vCPDesc;
    }

    public void setVCPDesc(String vCPDesc) {
        this.vCPDesc = vCPDesc;
    }

    public String getVCPProcedure() {
        return vCPProcedure;
    }

    public void setVCPProcedure(String vCPProcedure) {
        this.vCPProcedure = vCPProcedure;
    }

    public int getVCPRepeatDays() {
        return vCPRepeatDays;
    }

    public void setVCPRepeatDays(int vCPRepeatDays) {
        this.vCPRepeatDays = vCPRepeatDays;
    }

    public int getTaskMinutes() {
        return taskMinutes;
    }

    public void setTaskMinutes(int taskMinutes) {
        this.taskMinutes = taskMinutes;
    }

    public int getTaskMen() {
        return taskMen;
    }

    public void setTaskMen(int taskMen) {
        this.taskMen = taskMen;
    }

    public List<InventoryUsage> getInvUsageCollection() {
        return invUsageCollection;
    }

    public void setInvUsageCollection(List<InventoryUsage> invUsageCollection) {
        this.invUsageCollection = invUsageCollection;
    }

    @XmlTransient
    public Collection<VesselCleaningHistory> getVCHCollection() {
        return vchCollection;
    }

    public void setVCHCollection(Collection<VesselCleaningHistory> vchCollection) {
        this.vchCollection = vchCollection;
    }

    @XmlTransient
    public Collection<EquipmentCleaningHistory> getECHCollection() {
        return echCollection;
    }

    public void setECHCollection(Collection<EquipmentCleaningHistory> echCollection) {
        this.echCollection = echCollection;
    }

    public List<Documents> getDocumentsCollection() {
        return docCollection;
    }

    public void setDocumentsCollection(List<Documents> docCollection) {
        this.docCollection = docCollection;
    }

    public int getRateType() {
        return rateType;
    }

    public void setRateType(int rateType) {
        this.rateType = rateType;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (vcpid != null ? vcpid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof VesselCleaningProcedure)) {
            return false;
        }
        VesselCleaningProcedure other = (VesselCleaningProcedure) object;
        if ((this.vcpid == null && other.vcpid != null) || (this.vcpid != null && !this.vcpid.equals(other.vcpid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.VesselCleaningProcedure[ vcpid=" + vcpid + " ]";
    }
    
}
